<?php
/**
 * Retourne toutes les pages dynamiques publiées
 *
 * @return array associatif
 */
function select_pages()
{
	$db = option('db_conn');
	$sql = "
	SELECT * 
	FROM pages
	";
	$stmt = $db->prepare($sql);
	if ($stmt->execute())
	{
		return $stmt->fetchAll(PDO::FETCH_ASSOC);
	}
	return false;
}
/**
 * Retourne les informations d'une page à partir de son permalien
 *
 * @param string $permalien 
 * @return array
 */
function select_page($permalien)
{
	$db = option('db_conn');
	$sql = "
	SELECT * 
	FROM pages
	WHERE permalien = :permalien
	";
	$stmt = $db->prepare($sql);
	$stmt->bindValue(':permalien', $permalien, PDO::PARAM_STR);
	if ($stmt->execute() && $row = $stmt->fetch(PDO::FETCH_ASSOC))
	{
		return $row;
	}
	return null;
}
/**
 * Retourne les informations d'une page
 *
 * @param int $id 
 * @return array
 */
function select_page_id($id)
{
	$db = option('db_conn');
	$sql = "
	SELECT * 
	FROM pages 
	WHERE idpages = :id
	";
	$stmt = $db->prepare($sql);
	$stmt->bindValue(':id', $id, PDO::PARAM_STR);
	if ($stmt->execute() && $row = $stmt->fetch(PDO::FETCH_ASSOC))
	{
		return $row;
	}
	return null;
}
?>